/*
 See LICENSE folder for this sample’s licensing information.
 
 Abstract:
 The model for an individual landmark.
 */

import SwiftUI
import CoreLocation

struct Landmark: Hashable, Codable, Identifiable {
    var id: Int
    var name: String
    fileprivate var imageName: String
    fileprivate var coordinates: Coordinates
    var state: String
    var park: String
    var category: Category
    
    /// 是否收藏
    var isFavorite:Bool?
    
    /// 介绍
    var description:String?
    
    var locationCoordinate: CLLocationCoordinate2D {
        CLLocationCoordinate2D(
            latitude: coordinates.latitude,
            longitude: coordinates.longitude)
    }
    
    func image(forSize size: Int) -> Image {
        ImageStore.shared.image(name: imageName, size: size)
    }
    
    enum Category: String, CaseIterable, Codable, Hashable {
        case featured = "Featured"
        case lakes = "Lakes"
        case rivers = "Rivers"
    }
    
    ///防止服务端下发字段多余当前字段，而无法匹配解析
    struct Landmark: Decodable {
        var id: Int
        var name: String
        fileprivate var imageName: String
        fileprivate var coordinates: Coordinates
        var state: String
        var park: String
        var category: Category
        var isFavorite:Bool?
        var description:String?
    }
}

struct Coordinates: Hashable, Codable {
    var latitude: Double
    var longitude: Double
}
